package com.wn.controller;

import com.wn.annotation.RequireRoles;
import com.wn.entity.Guideinfo;
import com.wn.entity.Hottravelinfo;
import com.wn.service.HottravelinfoService;
import com.wn.utils.PageParam;
import com.wn.utils.Rsp;
import com.wn.utils.SystemControllerLog;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * (Hottravelinfo)表控制层
 *热门旅游目的地咨询
 * @author makejava
 * @since 2020-10-26 09:30:45
 */
@RestController
@RequestMapping("hottravelinfo")
public class HottravelinfoController {
    /**
     * 服务对象
     */
    @Resource
    private HottravelinfoService hottravelinfoService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Hottravelinfo selectOne(String id) {
        return this.hottravelinfoService.queryById(id);
    }

    @SystemControllerLog(description = "分页查询出行列表")
    @PostMapping("/searchSomeHottravelByPage")
    @RequireRoles(roles = {"admin","super_admin","reception","guide","tourist"},index = 1)
    @ApiOperation("查询所有用户 支持 多条件 分页 排序 查询")
    public Rsp searchSomeByPage(@RequestBody PageParam<Hottravelinfo> hottravelinfoPageParam,
       @RequestHeader("token") String token){

        return Rsp.success(hottravelinfoService.queryAllByLimit(hottravelinfoPageParam));
    }

    @SystemControllerLog(description = "添加出行信息")
    @PostMapping("/addOneHottravel")
    @RequireRoles(roles = {"admin","super_admin"},index = 1)
    public Rsp addOne(@RequestBody  Hottravelinfo hottravelinfo,
                      @RequestHeader("token") String token){

        return hottravelinfoService.insert(hottravelinfo);
    }

    @SystemControllerLog(description = "添加出行信息")
    @PostMapping("/deleteHottravelLogical")
    @RequireRoles(roles = {"admin","super_admin"},index = 1)
    public Rsp deleteUserLogical(@RequestBody Hottravelinfo hottravelinfo){

        return hottravelinfoService.deleteLogical(hottravelinfo);
    }


    @PostMapping("/updateHottravel")
    @RequireRoles(roles = {"admin","super_admin"},index = 1)
    public Rsp updateUser(@RequestBody Hottravelinfo hottravelinfo){

        return hottravelinfoService.update(hottravelinfo);
    }

}
